package com.ieslab.powergrid.demosvr.service;

import com.google.common.collect.Sets;
import com.ieslab.powergrid.demosvr.entity.Person;
import com.ieslab.powergrid.demosvr.entity.User;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
public class UserService {
    /**
     * 获取用户信息
     * @return Person
     */
    public Person getUser() {
        //这里直接构造用户类，实际需要读取数据库，此处省略
        return new Person("", "斌哥", "123456","jinan");
    }

    /**
     * 获取指定用户
     * @param username 用户名
     * @return
     */
    public User getByUsername(String username) {
        return new User(username, "123456");
    }

    /**
     * 获取用户角色
     * @param username 用户名
     * @return
     */
    public Set<String> getRoles(String username) {
        Set set = Sets.newHashSet();
        set.add("admin");
        return set;
    }

    /**
     * 获取用户权限
     * @param username 用户名
     * @return
     */
    public Set<String> getPermissions(String username) {
        Set set = Sets.newHashSet();
        set.add("index");
        set.add("yonghu");
        return set;
    }
}
